Summary

Circular buffer, push pop and index access is always O(1).

Properties

Capacity Maximum capacity of the buffer. Elements pushed into the buffer after maximum capacity is reached (IsFull = true), will remove an element.
IsEmpty True if has no elements.
IsFull Boolean indicating if Circular is at full capacity. Adding more elements when the buffer is full will cause elements to be removed from the other end of the buffer.
Item
Size Current buffer size (the number of elements that the buffer has).

Methods

Back Element at the back of the buffer - this[Size - 1].
Clear Clears the contents of the array. Size = 0, Capacity is unchanged.
Front Element at the front of the buffer - this[0].
GetEnumerator Returns an enumerator that iterates through this buffer.
PopBack Removes the element at the back of the buffer. Decreasing the Buffer size by 1.
PopFront Removes the element at the front of the buffer. Decreasing the Buffer size by 1.
PushBack
PushFront
ToArray Copies the buffer contents to an array, according to the logical contents of the buffer (i.e. independent of the internal order/contents)
ToArraySegments Get the contents of the buffer as 2 ArraySegments. Respects the logical contents of the buffer, where each segment and items in each segment are ordered according to insertion. Fast: does not copy the array elements. Useful for methods like <c>Send(IList&lt;ArraySegment&lt;Byte&gt;&gt;)</c>. <remarks>Segments may be empty.</remarks>
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.